package cn.wsalix.msg.entity;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import cn.anlaser.entity.CommonEntity;
import cn.wsalix.admin.entity.SysUser;
import cn.wsalix.type.MessTypeEnum;

import com.fasterxml.jackson.annotation.JsonIgnore;

@Entity
@DynamicInsert
@DynamicUpdate
@Table(name = "MESS_RAPPORT")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@EntityListeners({ AuditingEntityListener.class })
@Data
@EqualsAndHashCode(exclude = { "message" }, callSuper = false)
@ToString(exclude = { "message" })
public class MessRapport extends CommonEntity {
	/**
		 * 
		 */
	private static final long serialVersionUID = 8500867520550921062L;
	private String title;
	private boolean readed;

	private MessTypeEnum type;
	private Long fkId;
	@Temporal(TemporalType.TIMESTAMP)
	private Date sendTime;

	@JsonIgnore
	@ManyToOne(cascade = CascadeType.MERGE, optional = true, fetch = FetchType.LAZY)
	@JoinColumn(name = "MESS_ID")
	private Message message;
	@JsonIgnore
	@ManyToOne(cascade = CascadeType.MERGE, optional = true, fetch = FetchType.LAZY)
	@JoinColumn(name = "RECEIVE_ID")
	private SysUser receive;// 接收者

}